package com.jianglin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jianglin.mapper.CarchargeMapper;
import com.jianglin.model.Carcharge;
import com.jianglin.service.ICarchargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class CarchargeServiceImpl implements ICarchargeService {

    @Autowired
    private CarchargeMapper carchargeMapper;

    @Override
    public PageInfo<Carcharge> findCarchargeAll(int page, int pageSize, Carcharge carcharge) {
        PageHelper.startPage(page, pageSize);
        List<Carcharge> list = carchargeMapper.queryCarChargeAll(carcharge);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<Carcharge> findListByPage(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Carcharge> list = carchargeMapper.queryCarChargeAll(new Carcharge());
        return new PageInfo<>(list);
    }

    @Override
    public int add(Carcharge carcharge) {
        return carchargeMapper.insert(carcharge);
    }

    @Override
    public int delete(Integer id) { // 改为 Integer
        return carchargeMapper.delete(id);
    }

    @Override
    public int updateData(Carcharge carcharge) {
        return carchargeMapper.update(carcharge);
    }

    @Override
    public Carcharge findById(Integer id) { // 改为 Integer
        return carchargeMapper.findById(id);
    }
}
